/*
 * Copyright(c) 2018-? the original author[Wien(luweien@aliyun.com)] or authors.
 *
 */
package org.doll.it.linde.enums;

/**
 * 字段类型枚举
 * 
 * @author Wien(luweien@aliyun.com)
 *
 */
public enum FieldTypeEnum {

	/**
	 * ID类型
	 */
	ID(0, "ID"),

	/**
	 * 类型的类型
	 */
	TYPE(1, "类型"),

	/**
	 * 状态类型
	 */
	STATE(2, "状态"),

	/**
	 * 日期/时间类型
	 */
	DATE(3, "日期"),

	/**
	 * 布尔类型
	 */
	BOOLEAN(4, "布尔"),

	/**
	 * 整数类型
	 */
	INTEGER(5, "整数"),

	/**
	 * 小数类型
	 */
	NUMBER(6, "小数"),

	/**
	 * 下拉选择框类型
	 */
	PICK(7, "选择"),

	/**
	 * 文本类型
	 */
	TEXT(8, "文本"),

	/**
	 * 用户类型
	 */
	USER(9, "用户"),

	/**
	 * 动态选择类型（DynamicPick）
	 */
	DPICK(10, "动态选择"),

	/**
	 * 关联关系类型
	 */
	RELATIONSHIP(11, "关联关系"),

	/**
	 * 附件类型
	 */
	ATTACHMENT(12, "附件");

	private final int code;

	private final String message;

	private FieldTypeEnum(int code, String message) {
		this.code = code;
		this.message = message;
	}

	/**
	 * @return Return the integer value of this status code.
	 */
	public int getCode() {
		return code;
	}

	/**
	 * @return Return the reason phrase of this code.
	 */
	public String getMessage() {
		return message;
	}

	/**
	 * Return the enum constant of this type with the specified numeric value.
	 * @param code the numeric value of the enum to be returned
	 * @return the enum constant with the specified numeric value
	 * @throws IllegalArgumentException if this enum has no constant for the specified numeric value
	 */
	public static FieldTypeEnum valueOf(int code) {
		for (FieldTypeEnum typeEnum : values()) {
			if (typeEnum.getCode() == code) {
				return typeEnum;
			}
		}
		throw new IllegalArgumentException("No matching constant for [" + code + "]");
	}
}
